package cn.easier.activity.console.repository;

import cn.easier.activity.web.entity.ActivityRule;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * 活动规则 Repository
 */
@Repository
public interface ActivityRuleRepository extends JpaRepository<ActivityRule, Integer> {

    /**
     * 获取活动规则
     *
     * @param activityInfoId 活动编号
     * @return
     */
    ActivityRule findActivityRuleByActivityInfoId(Integer activityInfoId);

    ActivityRule findByActivityInfoId(Integer activityId);

    List<ActivityRule> findByActivityInfoIdIn(Collection<Integer> activityInfoId);

    ActivityRule findActivityRuleByActivityInfoIdAndPrizeClawType(Integer activityInfoId, String prizeClawType);

    @Query("select a from ActivityRule a where a.activityInfoId = :activityInfoId and a.prizeClawType = :PrizeClawType ")
    ActivityRule findPrizeClawByActivityInfoId(@Param("activityInfoId") Integer activityInfoId,@Param("PrizeClawType") String PrizeClawType);
}
